﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Module_File_Default : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.initializeWebForm();

        if (!IsPostBack)
        {
            Genesis.Client.Module.Classes.ModuleProvider moduleProvider = new Genesis.Client.Module.Classes.ModuleProvider();

            System.Data.DataTable fileTable = moduleProvider.FileGetList();

            System.Data.DataColumn editUrlColumn = new System.Data.DataColumn("EditUrl", typeof(string));
            System.Data.DataColumn fileVersionColumn = new System.Data.DataColumn("FileVersion", typeof(string));
            //System.Data.DataColumn deleteUrlColumn = new System.Data.DataColumn("DeleteUrl", typeof(string));

            fileTable.Columns.Add(editUrlColumn);
            fileTable.Columns.Add(fileVersionColumn);
            //applicationTable.Columns.Add(deleteUrlColumn);

            foreach (System.Data.DataRow row in fileTable.Rows)
            {
                string _rowUrl = string.Format("Detail.aspx?FileGuid={0}&FormMode=Edit",
                    row["FileGuid"]);

                row["EditUrl"] = string.Format("<a href=\"{0}\">{1}</a>",
                    this.buildForwardUrl(_rowUrl),
                    row["FileId"]);

                //row["DeleteUrl"] = string.Format("<a href=\"Detail.aspx?ApplicationGuid={0}&FormMode=Delete\"><img alt=\"Delete\" src=\"/Genesis.Management.Web/Images/trash.ico\" /></a>",
                //    row["ApplicationGuid"]);

                string _fileVersion = string.Format("{0}.{1}.{2}.{3}",
                    row["FileVersionMajor"],
                    row["FileVersionMinor"],
                    row["FileVersionBuild"],
                    row["FileVersionRevision"]);

                row["FileVersion"] = _fileVersion;
            }

            GridView1.DataSource = fileTable;
            GridView1.DataBind();
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect(this.buildForwardUrl("Detail.aspx?FormMode=Create"));
    }
}
